Hi all,
I want to export data from a DBF file to an Access table programatically.
I can export from a tab delimited text file but I don't have any idea how to do this from a DBF file.
Following is the code to export from a tab delimited text file
--------------------------------------------------------------
'strPath = the path of the text file to be exported into the Access table
Dim DB As DAO.Database, rs As DAO.Recordset
Dim str1 As String, str2 As Variant
Dim i As Integer
Set DB = CurrentDb
Set rs = DB.OpenRecordset("TableName")
Dim intFile As Integer
intFile = FreeFile
Open strPath For Input As intFile
Do While Not EOF(1)
Line Input #intFile, str1
If str1 <> "col1" & vbTab & "col2" & vbTab & "col3" & vbTab & "col4" & vbTab & "col5" & vbTab & "col6" & vbTab & "col7" & vbTab & "col8" & vbTab & "col9" & vbTab & "col10" & vbTab & "col11" & vbTab & "col12" & vbTab & "col13" & vbTab & "col14" & vbTab & "col15" & vbTab & "col16" & vbTab & "col17" Then
str2 = Split(str1, vbTab)
rs.AddNew
For i = 0 To UBound(str2)
On Error Resume Next
rs(i) = str2(i)
Next
rs.Update
End If
Loop
Close #intFile
rs.Close
--------------------------------------------------------------
Can anybody help me solving this issue.
Thanks
Priyanka
I want to export data from a DBF file to an Access table programatically.
I can export from a tab delimited text file but I don't have any idea how to do this from a DBF file.
Following is the code to export from a tab delimited text file
--------------------------------------------------------------
'strPath = the path of the text file to be exported into the Access table
Dim DB As DAO.Database, rs As DAO.Recordset
Dim str1 As String, str2 As Variant
Dim i As Integer
Set DB = CurrentDb
Set rs = DB.OpenRecordset("TableName")
Dim intFile As Integer
intFile = FreeFile
Open strPath For Input As intFile
Do While Not EOF(1)
Line Input #intFile, str1
If str1 <> "col1" & vbTab & "col2" & vbTab & "col3" & vbTab & "col4" & vbTab & "col5" & vbTab & "col6" & vbTab & "col7" & vbTab & "col8" & vbTab & "col9" & vbTab & "col10" & vbTab & "col11" & vbTab & "col12" & vbTab & "col13" & vbTab & "col14" & vbTab & "col15" & vbTab & "col16" & vbTab & "col17" Then
str2 = Split(str1, vbTab)
rs.AddNew
For i = 0 To UBound(str2)
On Error Resume Next
rs(i) = str2(i)
Next
rs.Update
End If
Loop
Close #intFile
rs.Close
--------------------------------------------------------------
Can anybody help me solving this issue.
Thanks
Priyanka